﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;

public class CameraFollowScript : MonoBehaviour {

    Transform player;

    float playerHeight;
    static float t = 0.015f;

    // Use this for initialization
    void Start ()
    {
        player = GameObject.FindGameObjectWithTag("Player").transform;
	}
	
	// Update is called once per frame
	void Update ()
    {

        playerHeight = player.position.y;

        float currentCameraHeight = transform.position.y;

        float newCameraHeight = Mathf.Lerp(currentCameraHeight, playerHeight + 1.75f, t);

        if (playerHeight > currentCameraHeight)
        {
            transform.position = new Vector3(transform.position.x, newCameraHeight, transform.position.z);
        }
        else
        {
            if (playerHeight < currentCameraHeight - 3.25f)
            {
                Debug.Log("death");
            }
        }
    }
}
